#!/usr/bin/env python
# -*- coding: utf-8 -*-
# Created by master on 2017/3/9

import threading

import time


# 继承式调用
def sayHi(num):
    print("running on number:%s" % num)

    time.sleep(3)


class MyThread(threading.Thread):
    def __init__(self, num):
        threading.Thread.__init__(self)  # 先继承父类的构造方法
        self.num = num

    def run(self):  # 必须实现run方法
        sayHi(self.num)


if __name__ == '__main__':
    t1 = MyThread(1)  # 生成一个线程实例
    t2 = MyThread(2)  #

    t1.start()
    t2.start()

    print(t1.getName())
    print(t2.getName())
